package com.zzyl.web;

import org.apache.qpid.proton.codec.Data;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.connection.DataType;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

@SpringBootTest
public class test {
    @Autowired
    private RedisTemplate<String,String> redisTemplate;
    @Test
    public void test01(){
        redisTemplate.opsForValue().set("city","wuhang");
        redisTemplate.opsForValue().set("city","beijing",20,TimeUnit.MINUTES);

    }
@Test
    public void test2(){
        redisTemplate.opsForHash().put("user","name","张三");
        Set<Object> list = redisTemplate.opsForHash().keys("user");
        List<Object> value = redisTemplate.opsForHash().values("user");
        redisTemplate.opsForHash().delete("user");
    }

    @Test
    public void test03(){
        redisTemplate.opsForSet().add("myset","a","b","c","d");
        redisTemplate.opsForSet().add("myset02","a","b","c","e");

        Set<String> members = redisTemplate.opsForSet().members("myset");
        redisTemplate.opsForSet().size("myset");

        redisTemplate.opsForSet().intersect("myset","myset02");
        redisTemplate.opsForSet().union("myset","myset02");
    }
    @Test
    public void test04(){
        redisTemplate.opsForList().leftPushAll("mylist","a","b");
        redisTemplate.opsForList().leftPush("mylist","e");
        redisTemplate.opsForList().range("mylist",0,-1);

    }
    @Test
    public void test05(){
        redisTemplate.opsForZSet().add("myzset","a",1);
        redisTemplate.opsForZSet().range("myzsez",0,-1);
        redisTemplate.opsForZSet().incrementScore("myzset","a",20);

    }
    @Test
    public void test06(){
        redisTemplate.keys("*");
        redisTemplate.hasKey("");
        redisTemplate.type("");
        redisTemplate.delete("");
    }

    }




